'''
Created on 2012-9-19

@author: zshe
'''
import MySQLdb
from crawler.conf import *

class BaseDao(object):
    '''
    Base dao
    '''
    
    def __init__(self):
        '''
        Pass
        '''
        pass
    
    def executemany(self, sqlTemplate, rows):
        try:
            conn = MySQLdb.connect(host=gDBHost, port=gDBPort, user=gDBUser, passwd=gDBPassword, db=gDBSchema, charset="utf8")
            cursor = conn.cursor()
            cursor.executemany(sqlTemplate, rows)
            cursor.close()
            conn.commit()
            conn.close()
        except Exception, e:
            print e